<template>
	<div>
		<div class="topTitle">商家简章公告</div>
		<el-form inline :model="query" label-width="80px">
			<el-form-item label="地区">
				<el-cascader :show-all-levels="false" :props="props" v-model="query.key" placeholder="请选择所属地区"
					class="margin-right10 width260">
				</el-cascader>
			</el-form-item>
			<el-form-item label="机构">
				<el-select v-model="query.userId" placeholder="请选择机构" class="width260 margin-right10">
					<el-option v-for="item in organAll" :key="item.id" :label="item.companyName" :value="item.id"></el-option>
				</el-select>
			</el-form-item>
			<el-form-item label="科目">
				<el-select clearable placeholder="请选择科目" v-model="query.appid" class="width260 margin-right10">
					<el-option v-for="(item,index) in miniData" :key="index" :label="item.name" :value="item.id"></el-option>
				</el-select>
			</el-form-item>
			<el-form-item label="状态">
				<el-select v-model="query.applyStatus" placeholder="请选择状态" class="width260 margin-right10">
					<el-option label="发布" :value="1"></el-option>
					<el-option label="报名中" :value="2"></el-option>
					<el-option label="报名结束" :value="3"></el-option>
					<el-option label="考试结束" :value="4"></el-option>
					<el-option label="公告发布" :value="5"></el-option>
				</el-select>
			</el-form-item>
			<el-form-item label="标题名称">
				<el-input v-model="query.title" placeholder="请输入关键字" class="width260 margin-right10"></el-input>
			</el-form-item>
			<el-form-item label="发布时间">
				<el-date-picker v-model="dateTime" type="datetimerange" range-separator="至" start-placeholder="开始日期"
					end-placeholder="结束日期" value-format="yyyy-MM-dd HH:mm:ss" @change="onDateChange">
				</el-date-picker>
			</el-form-item>
			<el-form-item>
				<el-button type="primary" icon="el-icon-search" class="margin-left10" @click="handleSearch">搜索</el-button>
				<el-button type="default" icon="el-icon-refresh-right" @click="handleRefresh">重置</el-button>
			</el-form-item>
		</el-form>
		<div class="margin-bottom20">
			<!-- <el-button type="primary" @click="handleAdd">新建</el-button> -->
		</div>
		<el-table :data="tableData" border header-cell-class-name="table-header-style">
			<el-table-column label="序号" type="index" align="center" width="80"></el-table-column>
			<el-table-column label="ID" prop="id" align="center" width="80"></el-table-column>
			<el-table-column label="状态" prop="status" align="center">
				<template slot-scope="{row}">
					<span v-if="row.applyStatus==1">发布</span>
					<span v-else-if="row.applyStatus==2">报名中</span>
					<span v-else-if="row.applyStatus==3">报名结束</span>
					<span v-else-if="row.applyStatus==4">考试结束</span>
					<span v-else-if="row.applyStatus==5">公告发布</span>
				</template>
			</el-table-column>
			<el-table-column label="标题" prop="title" width="400"></el-table-column>
			<el-table-column label="发布机构" prop="organName" align="center"></el-table-column>
			<el-table-column label="公告类型" prop="categoryName" align="center"></el-table-column>
			<el-table-column label="公告年份" prop="year" align="center"></el-table-column>
			<el-table-column label="公告地区" prop="city" align="center">
				<template slot-scope="scope">
					{{scope.row.cityName}}{{scope.row.provinceName}}
				</template>
			</el-table-column>
			<el-table-column label="发布时间" prop="publishDate" align="center"></el-table-column>
			<el-table-column label="阅读量" prop="readNum" align="center"></el-table-column>
			<el-table-column label="状态" align="center">
				<template slot-scope="{row}">
					<span v-if="row.status==0">待审核</span>
					<span v-else-if="row.status==1">审核通过</span>
					<span v-else-if="row.status==2">审核失败</span>
				</template>
			</el-table-column>
			<el-table-column label="操作" align="center" width="200">
				<template slot-scope="scope">
					<el-button type="text" @click="handleAdd(scope.row,1)">预览</el-button>
					<el-button type="text" @click="handleAdd(scope.row,2)">引用发布</el-button>
					<el-popconfirm title="确定删除吗？" @confirm="handleDel(scope.row.id)">
						<el-button type="text" slot="reference">删除</el-button>
					</el-popconfirm>
				</template>
			</el-table-column>
		</el-table>
		<div class="margin-top10">
			<el-pagination background layout="->,total,sizes, prev, pager, next" :current-page="query.pageNumber"
				:page-sizes="[30, 40, 50, 60]" @size-change="handleSizeChange" :page-size="query.pageSize" :total="pageTotal"
				@current-change="handlePageChange"></el-pagination>
		</div>

		<!-- 新建编辑公告 -->
		<el-dialog :title="title" :visible.sync="visible" v-if="visible" width="65%">
			<el-form :model="form" label-width="120px">
				<el-form-item label="简章标题" :required="true">
					<el-input v-model="form.title" placeholder="请输入简章标题"></el-input>
				</el-form-item>
				<div class="row-me flex-wrap">
					<el-form-item label="发布类型" :required="true">
						<el-select v-model="form.targetId" placeholder="请选择" class="width260 margin-right10">
							<el-option v-for="(item,index) in typeList" :key="index" :value="item.id" :label="item.name">
							</el-option>
						</el-select>
					</el-form-item>
					<el-form-item label="发布地区" :required="true">
						<el-cascader :props="addProps" v-model="form.codeShow" :options="areaData" placeholder="请选择地区"
							class="width260 margin-right10" @change="addAreaChange"></el-cascader>
					</el-form-item>
					<el-form-item label="发布年份" :required="true">
						<el-date-picker v-model="form.year" type="year" placeholder="请选择发布年份" value-format="yyyy">
						</el-date-picker>
					</el-form-item>
				</div>
				<el-form-item label="公告分类" :required="true">
					<div class="row-me row-center">
						<el-select v-model="form.categoryId" class="width100Per" placeholder="请选择分类">
							<el-option v-for="item in categorysData" :key="item.id" :label="item.name" :value="item.id">
							</el-option>
						</el-select>
						<el-button type="text" @click="clickCreateType" class="margin-left20">新建分类</el-button>
					</div>
				</el-form-item>
				<el-form-item label="简章内容" :required="true">
					<WangEditor v-model="form.content" width="90%" :height="300"></WangEditor>
				</el-form-item>
				<el-form-item label="是否显示摘要" :required="true">
					<div class="row-me">
						<el-switch v-model="form.isSummary" class="line-height40"></el-switch>
						<div class="row-me flex-wrap" v-if="form.isSummary">
							<el-form-item label="报名时间" :required="true">
								<el-date-picker v-model="form.applyDate" type="datetimerange" range-separator="至"
									start-placeholder="开始日期" end-placeholder="结束日期" value-format="yyyy-MM-dd HH:mm"
									@change="onApplyDateChange" class="margin-bottom10" format="yyyy-MM-dd HH:mm">
								</el-date-picker>
							</el-form-item>
							<el-form-item label="考试时间" :required="true">
								<el-date-picker v-model="form.examDate" type="date" placeholder="请选择考试时间"
									value-format="yyyy-MM-dd HH:mm:ss" style="width: 260px;" class="margin-bottom10">
								</el-date-picker>
							</el-form-item>
							<el-form-item label="招收人数" :required="true">
								<el-input class="width260 margin-bottom10" placeholder="请输入招收人数" v-model="form.recruitNum"></el-input>
							</el-form-item>
							<el-form-item label="考试内容" :required="true">
								<el-input class="width260 margin-bottom10" placeholder="请输入考试内容" v-model="form.examContent"></el-input>
							</el-form-item>
						</div>
						<el-form-item label="固定标签" v-else :required="true">
							<el-input v-model="form.summary" placeholder="请输入固定标签" class="width260"></el-input>
						</el-form-item>
					</div>
				</el-form-item>
				<div class="row-me flex-wrap">
					<el-form-item label="虚拟浏览量" :required="true">
						<el-input placeholder="请输入虚拟浏览量" v-model="form.virtualReadNum" class="width260"></el-input>
					</el-form-item>
					<el-form-item label="自增设置" :required="true">
						<div class="row-me">
							<el-switch v-model="form.isAdd" class="line-height40 margin-right20"></el-switch>
							<div class="row-me" v-if="form.isAdd">
								<el-input class="width120" placeholder="请输入最小值" v-model="form.addMin"></el-input>
								<span class="margin-left5 margin-right5">~</span>
								<el-input class="width120" placeholder="请输入最大值" v-model="form.addMax"></el-input>
								<el-select placeholder="请选择每30分钟/每小时/每天" class="margin-left30 width200" v-model="form.addTime">
									<el-option label="每30分钟" :value="1"></el-option>
									<el-option label="每小时" :value="2"></el-option>
									<el-option label="每天" :value="3"></el-option>
								</el-select>
							</div>
						</div>
					</el-form-item>
				</div>
				<el-form-item label="添加附件" :required="true">
					<singleUploadLocal :value="fileList" isFile message="支持扩展名: .doc .xls .pdf .rar .zip格式上传,大小不超过200M"
						@input="getFile">
					</singleUploadLocal>
				</el-form-item>
				<el-form-item label="上传分享图标" :required="true">
					<el-image v-if="form.image" class="width100 height100 radius6 margin-right10" :src="form.image"
						:preview-src-list="[form.image]"></el-image>
					<el-button type="text" @click="clickImg3">点击图片库(分享图标)</el-button>

					<!-- <uploadLocal :value="iconFileList" @input="getImgData" :maxCount="1" :fileSize="5"></uploadLocal> -->
				</el-form-item>
				<el-form-item label="发布人" :required="true">
					<el-input placeholder="请输入发布人" v-model="form.publishBy" class="width260"></el-input>
				</el-form-item>
				<el-form-item label="发布时间" :required="true">
					<el-date-picker v-model="form.publishDate" type="date" placeholder="请选择发布时间"
						value-format="yyyy-MM-dd HH:mm:ss" style="width: 260px;">
					</el-date-picker>
				</el-form-item>
			</el-form>
			<span slot="footer" class="dialog-footer" v-if="title != '详情'">
				<el-button @click="visible = false">取 消</el-button>
				<el-button @click="handleSave" type="primary">确 认</el-button>
			</span>
		</el-dialog>

		<!-- 新增编辑分类 -->
		<el-dialog title="分类" :visible.sync="typeVisible" width="40%" @close="getCategotyData">
			<el-table :data="typeTableData" border>
				<el-table-column label="分类名称" align="center">
					<template slot-scope="{row}">
						<el-input v-model="row.name" v-if="row.isEdit"></el-input>
						<span v-else>{{row.name}}</span>
					</template>
				</el-table-column>
				<el-table-column label="操作" align="center" width="200">
					<template slot-scope="scope">
						<el-button type="text" v-if="scope.row.isEdit" @click="handleTypeAdd(scope.row)">保存</el-button>
						<el-button type="text" @click="$set(scope.row,'isEdit',true)" v-else>编辑</el-button>
						<el-popconfirm title="确认删除？" @confirm="handleTypeDel(scope.row.id)">
							<el-button slot="reference" type="text">删除</el-button>
						</el-popconfirm>
					</template>
				</el-table-column>
			</el-table>
			<div class="margin-top10">
				<el-pagination background layout="->,total,sizes, prev, pager, next" :current-page="typeQuery.pageNumber"
					:page-sizes="[10, 20, 30, 40]" @size-change="handleSizeTypeChange" :page-size="typeQuery.pageSize"
					:total="pageTypeTotal" @current-change="handlePageTypeChange"></el-pagination>
			</div>
			<div class="margin-top20 row-me center-all">
				<el-input v-model="typeQuery.name" placeholder="请输入分类名称" class="margin-right20 width300"
					@input="onInput"></el-input>
				<el-button type="primary" @click="handleTypeAdd">新增</el-button>
			</div>
			<span slot="footer">
				<el-button type="primary" @click="typeVisible = false">关 闭</el-button>
			</span>
		</el-dialog>
		<imgLibrary ref="image" @handleImgOk="handleImgOk3"></imgLibrary>
	</div>
</template>

<script>
	import WangEditor from '@/components/wangeditor'
	import uploadLocal from "@/components/Upload/multiUploadLocal"
	import singleUploadLocal from "@/components/Upload/singleUploadLocal"
	import imgLibrary from "@/components/imgLibrary"
	export default {
		components: {
			uploadLocal,
			WangEditor,
			singleUploadLocal,
			imgLibrary
		},
		data() {
			return {
				query: {
					pageNumber: 1,
					pageSize: 30
				},
				tableData: [],
				pageTotal: 0,
				props: {
					emitPath: false,
					lazy: true,
					lazyLoad: this.lazyLoad2,
					checkStrictly: true,
				},
				props1: {
					emitPath: false,
					lazy: true,
					lazyLoad: this.lazyLoad,
					checkStrictly: true,
					multiple: true
				},
				areaData: [],
				organAll: [],
				miniData: [],
				dateTime: [],
				title: '',
				visible: false,
				form: {},
				iconFileList: [],
				typeList: [],
				isDetail: false,
				labelList: [],
				fileList: [],
				area: [],
				categorysData: [],
				typeVisible: false,
				typeTableData: [],
				typeQuery: {
					pageNumber: 1,
					pageSize: 10
				},
				pageTypeTotal: 0,
				addProps: {
					value: 'id',
					label: 'name',
					checkStrictly: true,
					multiple: true
				},
			}
		},
		mounted() {
			this.getOrganAll()
			this.getAll()
			this.getTagList()
			this.getData()
			this.listLevel1Way()
			this.getCategotyData()
			this.getAllArea()
		},
		methods: {
			onApplyDateChange(val) {
				this.form.applyStartDate = ''
				this.form.applyEndDate = ''
				if (val && val.length != 0) {
					this.form.applyStartDate = val[0]
					this.form.applyEndDate = val[1]
				}
			},
			addAreaChange(val) {
				this.form.codeShow = []
				this.form.province = []
				this.form.city = []
				if (val.length != 0) {
					this.form.codeShow = val
					for (let item of val) {
						if (item[0] || item[0] === 0) {
							if (item[0] === 0) {
								this.form.province.push(item[0])
								this.form.city.push(item[0])
							} else {
								this.form.province.push(item[0])
							}
						}
						if (item[1]) {
							this.form.city.push(item[1])
						}
					}
				}
				this.form.province = [...new Set(this.form.province)]
				this.form.city = [...new Set(this.form.city)]
			},
			//获取省市区树
			async getAllArea() {
				const res = await this.$get('/admin/area/getAllArea')
				if (res.code == 1000) {
					this.areaData = this.$.getTreeData(res.data)
					this.areaData.unshift({
						adcode: '0',
						name: '默认',
						parentId: 0,
						id: '0'
					})
				}
			},
			onInput(val) {
				this.$forceUpdate()
			},
			//分类分页
			handlePageTypeChange(val) {
				this.typeQuery.pageNumber = val
				this.getTypeData();
			},
			handleSizeTypeChange(val) {
				this.typeQuery.pageSize = val
				this.getTypeData();
			},
			//点击新建分类
			clickCreateType() {
				this.getTypeData()
				this.typeVisible = true
				this.typeQuery.name = ''
			},
			// 新增编辑分类
			handleTypeAdd(row) {
				let params = {
					name: this.typeQuery.name
				}
				if (row.id) {
					params = {
						id: row.id,
						name: row.name
					}
				}
				this.$post('/admin/articleNotice/saveArticleCategory', params).then(res => {
					if (res.code == 1000) {
						this.$message.success('编辑成功')
						this.getTypeData()
						row.isEdit = false
					}
				})
				this.typeQuery.name = ''
			},
			//删除分类
			async handleTypeDel(id) {
				const res = await this.$get('/admin/articleNotice/deleteCategory', {
					id
				})
				if (res.code == 1000) {
					this.$message.success('删除成功')
					this.getTypeData()
				}
			},
			//获取分类数据
			async getTypeData() {
				const res = await this.$get('/admin/articleNotice/pageCategory', this.typeQuery)
				if (res.code == 1000) {
					this.typeTableData = res.data.list
					this.pageTypeTotal = res.data.totalRow
				}
			},
			//获取公告分类
			async getCategotyData() {
				const res = await this.$get('/admin/articleNotice/getCategory')
				if (res.code == 1000) {
					this.categorysData = res.data
				}
			},
			cityChange(val) {
				console.log(val, "ppp")
				// if (val.split('_')[1] == 0) {
				// 	this.form.provinces = val.split('_')[2] || ''
				// } else if (val.split('_')[1] == 1) {
				// 	this.form.provinces = val.split('_')[2] || ''
				// 	this.form.cityName = val.split('_')[3] || ''
				// }
				let cityName = []
				let provinces = []
				if (val.length != 0) {
					for (let item of val) {
						if (item.split('_')[1] == '1') {
							cityName.push(item.split('_')[2])
						} else {
							provinces.push(item.split('_')[2])
						}
					}
				}
				this.form.cityName = cityName.join(',') || ''
				this.form.provinceName = provinces.join(',') || ''
			},
			handleImgOk3(data) {
				this.$set(this.form, 'image', data)
			},
			clickImg3() {
				this.$refs.image.show()
			},
			listLevel1Way() {
				this.$get('/admin/studyGuide/listLevel1', {}).then(res => {
					if (res.code == 1000) {
						this.typeList = res.data;
					}
				})
			},

			//获取附件
			getFile(data) {
				this.form.attach = []
				if (data && data.length != 0) {
					for (var i = 0; i < data.length; i++) {
						this.form.attach.push({
							title: '附件' + (i + 1),
							value: data[i]
						})
					}
				}
			},
			//获取标签下拉
			async getTagList() {
				const res = await this.$post('/admin/label/labelList')
				if (res.code == 1000) {
					this.labelList = res.data.list
				}
			},
			handleAdd(row, type) {
				this.form = {};
				if (row.id) {
					this.title = '引用发布'

					if (type == 1) {
						this.isDetail = true
						this.title = '详情'
					}
					this.form = JSON.parse(JSON.stringify(row));

					if (!this.$.isEmpty(this.form.addMin) || !this.$.isEmpty(this.form.addMax) || !this.$.isEmpty(this.form
							.addTime)) {
						this.form.isAdd = true;
					}


					if (!this.$.isEmpty(this.form.city)) {
						this.area = this.form.city.split(",")
					}

					this.fileList = []
					if (!this.$.isEmpty(this.form.attach)) {
						this.form.attach = JSON.parse(this.form.attach)
						for (let item of this.form.attach) {
							this.fileList.push({
								name: item.value,
								url: item.value
							})
						}
					}
					this.form.codeShow = this.form.codeShow ? JSON.parse(this.form.codeShow) : []
					if (this.form.applyStartDate && this.form.applyEndDate) {
						this.form.applyDate = [this.form.applyStartDate, this.form.applyEndDate]
					}
				} else {
					this.title = '新建'
				}
				this.visible = true
			},
			//删除
			async handleDel(id) {
				// const res = await this.$get('/admin/articleNotice/deleteCategory', {
				// 	id
				// })
				// if (res.code == 1000) {
				// 	this.$message.success('删除成功')
				// 	this.getData()
				// }
				this.$postForm('/admin/articleNotice/articleNoticeDeleted', {
					id: id,
				}).then((res) => {
					if (res.code == 1000) {
						this.$message.success('删除成功')
						this.getData()
					}
				}).catch((error) => {
					console.log(error)
				})

			},
			// 点击保存
			handleSave() {
				// 简章标题   form.title    发布类型  form.categoryId     发布地区   area      
				// 发布年份  form.year    简章内容  form.content    是否显示摘要  form.isSummary     


				if (this.$.isEmpty(this.form.title)) {
					this.$message.error('简章标题不能为空!')
					return
				}
				if (this.$.isEmpty(this.form.categoryId)) {
					this.$message.error('公告不能为空!')
					return
				}
				if (this.$.isEmpty(this.form.year)) {
					this.$message.error('发布年份不能为空!')
					return
				}
				if (this.$.isEmpty(this.form.content)) {
					this.$message.error('简章内容不能为空!')
					return
				}

				// 报名时间   form.applyStartDate    考试时间  form.examDate    招收人数   form.recruitNum
				// 考试内容  form.examContent     固定标签  form.labelName1   虚拟浏览量  form.virtualReadNum   


				if (this.form.isSummary == true) {
					if (this.$.isEmpty(this.form.applyStartDate)) {
						this.$message.error('请选择报名时间!')
						return
					}
				}

				if (this.form.isSummary == true) {
					if (this.$.isEmpty(this.form.examDate)) {
						this.$message.error('请选择考试时间!')
						return
					}
				}

				if (this.form.isSummary == true) {
					if (this.$.isEmpty(this.form.examDate)) {
						this.$message.error('请输入招收人数!')
						return
					}
				}
				if (this.form.isSummary == true) {
					if (this.$.isEmpty(this.form.examContent)) {
						this.$message.error('请输入考试内容!')
						return
					}
				}


				if (this.$.isEmpty(this.form.virtualReadNum)) {
					this.$message.error('虚拟浏览量不能为空!')
					return
				}

				// 自增设置  form.isAdd    请输入最小值  form.addMin   请输入最大值   form.addMax   请选择每30分钟/每小时/每天  form.addTime

				if (this.form.isAdd == true) {
					if (this.$.isEmpty(this.form.addMin)) {
						this.$message.error('请输入最小值!')
						return
					}
				}

				if (this.form.isAdd == true) {
					if (this.$.isEmpty(this.form.addMin)) {
						this.$message.error('请输入最大值!')
						return
					}
				}

				if (this.form.isAdd == true) {
					if (this.$.isEmpty(this.form.addTime)) {
						this.$message.error('请选择每30分钟/每小时/每天!')
						return
					}
				}



				// 添加附件  fileList 上传分享图标    form.image    发布人  form.publishBy   发布时间  form.publishDate
				if (this.$.isEmpty(this.form.image)) {
					this.$message.error('请上传分享图标!')
					return
				}
				if (this.$.isEmpty(this.form.publishBy)) {
					this.$message.error('请输入发布人!')
					return
				}
				if (this.$.isEmpty(this.form.publishDate)) {
					this.$message.error('请选择发布时间!')
					return
				}
				if (this.form.attach && this.form.attach.length != 0) {
					this.form.attach = JSON.stringify(this.form.attach)
				}
				this.form.codeShow = this.form.codeShow ? JSON.stringify(this.form.codeShow) : ''

				if (this.form.id) {
					delete this.form.id
				}
				this.$post('/admin/articleNotice/addArticleNotice', this.form).then((res) => {
					if (res.code == 1000) {
						this.$message.success('保存成功')
						this.getData();
						this.visible = false;
					}
				}).catch((error) => {
					console.log(error)
				})
			},
			//分页
			handlePageChange(val) {
				this.query.pageNumber = val
				this.getData();
			},
			handleSizeChange(val) {
				this.query.pageSize = val
				this.getData();
			},
			//获取列表数据
			async getData() {
				this.query.roleType = 2
				const res = await this.$get('/admin/articleNotice/pageArticleNotice', this.query)
				if (res.code == 1000) {
					this.tableData = res.data.list
					this.pageTotal = res.data.totalRow
				}
			},
			//搜索
			handleSearch() {
				this.query.pageNumber = 1
				this.getData();
			},
			//重置
			handleRefresh() {
				this.query = {
					pageNumber: 1,
					pageSize: 30
				}
				this.dateTime = []
				this.getData();
			},
			//发布时间变动
			onDateChange(val) {
				if (val.length == 0) {
					this.query.startTime = ''
					this.query.endTime = ''
				} else {
					this.query.startTime = val[0]
					this.query.endTime = val[1]
				}
			},
			//获取所有科目
			async getAll() {
				const res = await this.$get('/admin/minis/getAll')
				if (res.code == 1000) {
					this.miniData = res.data
				}
			},
			//获取机构下拉
			async getOrganAll() {
				const res = await this.$postForm('/admin/messages/organAll', {
					pageNumber: 1,
					pageSize: 9999
				})
				if (res.code == 1000) {
					this.organAll = res.data.list
				}
			},
			//报考地区变动
			areaChange(e) {
				if (e.length != 0) {
					if (e.split('_')[1] == '1') {
						this.query.cityName = e.split('_')[2]
					} else {
						this.query.province = e.split('_')[2]
					}
				}
			},
			getProvince() {
				var vm = this;
				return new Promise(function(resolve) {
					vm.$get('/admin/area/getProvince')
						.then(function(response) {
							response.data.unshift({
								name: '默认',
								id: '0'
							});
							vm.citys = response.data;
							resolve();
						});
				});
			},
			getCity(val) {
				var vm = this;
				return new Promise(function(resolve) {
					if (val == undefined || val == '0') {
						resolve([{
							name: '默认',
							id: ''
						}]);
					} else {
						vm.$get('/admin/area/getCities', {
								provinceId: val,
							})
							.then(function(response) {
								resolve(response.data);
							});
					}
				});
			},
			//加载省市选择项
			lazyLoad2(node, resolve) {
				let vm = this;
				if (node.level == 0) {
					this.getProvince(node.value).then(() => {
						const nodes = vm.citys.map(item => ({
							value: item.adcode,
							label: item.name,
							leaf: node.level >= 2
						}));
						resolve(nodes);
					});
				} else {
					this.getCity(node.value.split('_')[0]).then(city => {
						const nodes = city.map(item => ({
							value: item.adcode,
							label: item.name,
							leaf: node.level >= 2
						}));
						resolve(nodes);
					});
				}
			},
			lazyLoad(node, resolve) {
				let vm = this;
				if (node.level == 0) {
					this.getProvince(node.value).then(() => {
						const nodes = vm.citys.map(item => ({
							value: item.id + '_' + '0_' + item.name,
							label: item.name,
							leaf: node.level >= 2
						}));
						resolve(nodes);
					});
				} else {
					this.getCity(node.value.split('_')[0]).then(city => {
						const nodes = city.map(item => ({
							value: item.id + '_' + '1_' + item.name,
							label: item.name,
							leaf: node.level >= 2
						}));
						resolve(nodes);
					});
				}
			},
		}
	}
</script>